<?php 
$length = isset($_COOKIE['paginationLength'])?$_COOKIE['paginationLength']:12;
if ($_POST && isset($_POST['paginationLength'])){
    setcookie('paginationLength',$_POST['paginationLength']);
    $length = $_POST['paginationLength'];
}
?>
<form action="" method="post" id="paginationForm">
<select id="paginationSelect" name="paginationLength" style="display:none;">
<option value="12"></option>
<option value="20"></option>
<option value="30"></option>
</select>
<div class="pagination">
	<?php if ($first_page !== FALSE): ?>
		<span><a href="<?php echo $page->url($first_page) ?>" rel="first">&lt;&lt;</a></span>
	<?php else: ?>
		<span style="color:#CCCCCC;display:inline-block;padding:3px">&lt;&lt;</span>
	<?php endif ?>

	<?php if ($previous_page !== FALSE): ?>
		<span><a href="<?php echo $page->url($previous_page) ?>" rel="prev">上一页</a></span>
	<?php else: ?>
		<span style="color:#CCCCCC;display:inline-block;padding:3px">上一页</span>
	<?php endif ?>

	<?php if ($first_page):?>
	<span>...</span>
	<?php endif;?>
	
	<?php for ($i = ($last_page?max(1,$current_page-1):max(1,$current_page-2)); $i <= ($first_page?min($total_pages,$current_page+1):min($total_pages,$current_page+2)); $i++): ?>

		<?php if ($i == $current_page): ?>
			<a class="current" href="<?php echo $page->url($i) ?>"><?php echo $i ?></a>
		<?php else: ?>
			<a href="<?php echo $page->url($i) ?>"><?php echo $i ?></a>
		<?php endif ?>

	<?php endfor ?>

	<?php if ($last_page):?>
	<span>...</span>
	<?php endif;?>
	
	<?php if ($next_page !== FALSE): ?>
		<span><a href="<?php echo $page->url($next_page) ?>" rel="next">下一页</a></span>
	<?php else: ?>
		<span style="color:#CCCCCC;display:inline-block;padding:3px">下一页</span>
	<?php endif ?>

	<?php if ($last_page !== FALSE): ?>
		<span><a href="<?php echo $page->url($last_page) ?>" rel="last">&gt;&gt;</a></span>
	<?php else: ?>
		<span style="color:#CCCCCC;display:inline-block;padding:3px">&gt;&gt;</span>
	<?php endif ?>

</div><!-- .pagination -->
</form>
<script type="text/javascript">
<!--
function paginationLength(length){
	$('#paginationSelect option[value='+length+']').attr('selected', 'selected');
	$('#paginationForm').submit();
}
//-->
</script>